package com.gupao.jly521.pattern.simple;

import com.gupao.jly521.entity.ExportData0Entity;
import com.gupao.jly521.entity.ExportData1Entity;
import com.gupao.jly521.entity.ExportData2Entity;
import com.gupao.jly521.entity.ExportDataBaseEntity;

/**
 * @author Jly
 * @date 2018/8/17  14:04
 */
public class SimpleFactory {

    /**
     *  根据名称匹配不同的导出对象
     * @date 2018/8/17 14:09
     * @author Jly
     * @param [name]
     * @return com.gupao.jly521.simple.entity.ExportDataBaseEntity
     */
    public ExportDataBaseEntity createEntity(String name){
        if (name.equals("Data0")){
            return new ExportData0Entity();
        }else if (name.equals("Data1")) {
            return new ExportData1Entity();
        }else if (name.equals("Data2")) {
            return new ExportData2Entity();
        }
        return null;
    }

    public static void main( String[] args )
    {
        //简单工厂实例：
        SimpleFactory factory = new SimpleFactory();
        System.out.println(factory.createEntity("Data2").getCommonColumn());
    }
}
